var pathName=window.document.location.pathname;
var path=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
var FormView = function(id,setting){
	this.id = id;
	this.setting = setting;
}
var retJson;
var ueCashRule,ueMemberRule,ueRaiderEntrance,ueMoneyRaider,ueMoneyRule,ueComProblem,ueAboutUs,ueRegProtocol,ueNoticeNote;
var ueDemoNote;
FormView.prototype.initview = function(id){
    var inputs = $('#'+this.id).find("span[uitype]");
    $.ajax({
       url:g_path + "/public/tool/loadFormData.htmls",
       type:"POST",
       dataType:"json",
       data:{poName:this.setting.po,id:id},
       success:function(ret){
          $("td[uitype]").each(function(i,el){
             var name = $(el).attr("name");
             if($(el).attr("uitype")=="img"){
               $(el).html("<img src='"+ret[name]+"' style='width:60px;' />");
             }
             else if($(el).attr("uitype")=="is"){
               var val=ret[name]==1?"是":"否";
               $(el).html(val);
             }
             else{
               $(el).html(ret[name]);
             }
          });
       }
    });
}
FormView.prototype.initwebview = function(id){
    var inputs = $('#'+this.id).find("span[uitype]");
    $.ajax({
       url:g_path + "/interface/loadFormData.htmls",
       type:"POST",
       dataType:"json",
       data:{poName:this.setting.po,id:id},
       success:function(ret){
          $("*[uitype]").each(function(i,el){
             var name = $(el).attr("name");
             if($(el).attr("uitype")=="img"){
                $(el).html("<img src='"+ret[name]+"' />");
             }
             else if($(el).attr("uitype")=="val"){
                $(el).val(ret[name]);
             }
             else{
                $(el).html(ret[name]);
             }
          });
       }
    });
}
FormView.prototype.init = function(){
	var that = this;
	var wrap = $('#'+that.id);
	$.ajax({
		dataType: "json",
		async:false,
		url:path+'/public/frame/formview.htmls',
		data:{"data":this.setting.data},
		type:'POST',
		success:function(ret){
			$('#'+that.id).html("");
			var table = $("<table width='100%' border='0' cellspacing='0' cellpadding='0' class='ctable'></table>");
			for(var rowIndex=0;rowIndex<that.setting.fields.length;rowIndex++){
			    var strclass=rowIndex%2?"class='tr_space'":"";
				var tr = $("<tr></tr>").attr("rowIndex",rowIndex+1).appendTo(table);

				var cellDatas = that.setting.fields[rowIndex];
				for(var cellIndex=0;cellIndex<cellDatas.length;cellIndex++){
					var cellData = cellDatas[cellIndex];
					if(cellData.trdisplay){
                    	tr.attr("style",cellData.trdisplay);
                    }
					var td = $("<td style='text-align:right;width:"+cellData.tdwidth+"px' align='right'>"+(cellData['title'].length==0?"&nbsp;":cellData['title'])+"</td>").appendTo(tr);
					var td2 = $('<td></td>').appendTo(tr);
					if(cellData.colspan){
						td2.attr("colspan",cellData.colspan);
					}
					switch(cellData.type){
					case "blank":td2.html("&nbsp;");
						break;

					case "password":
					case "text":
					case "int":
						var type = cellData.type;
						type = type=="int"?"text":type;
						var input = $("<input uiType='"+cellData.type+"' type='"+type+"'>").appendTo(td2);
						if(cellData.unit){
						   td2.append("<span style='margin-left:5px;'>"+cellData.unit+"</span>");
						}
						if(cellData.name){
							input.attr("name",cellData.name);
						}
						if(cellData.id){
							input.attr("id",cellData.id);
						}else{
							input.attr("id",that.id+"_"+cellData.name);
						}
						if(cellData.width){
							input.css("width",cellData.width);
						}
						if(cellData.disabled){
							input.attr("disabled",cellData.disabled);
						}
						if(cellData.datatype&&cellData.msg){
						    input.attr("datatype",cellData.datatype);
						    input.attr("msg",cellData.msg);
						}
						if(cellData.value){
						    input.val(cellData.value);
						}
						if(cellData.field){
                        	input.attr("field",cellData.field);
                        }
						input.val(cellData.value);
						break;
					case "file":
					    var input = $("<input type='file' uiType='"+cellData.type+"' onchange='uploadfile(this)' />").appendTo(td2);
					    if(cellData.name){
                        	input.attr("name",cellData.name);
                        }
                        if(cellData.id){
                        	input.attr("id",cellData.id);
                        }else{
                        	input.attr("id",that.id+"_"+cellData.name);
                        }
                        if(cellData.width){
                        	input.css("width",cellData.width);
                        }
                        if(cellData.disabled){
                        	input.attr("disabled",cellData.disabled);
                        }
                        if(cellData.datatype&&cellData.msg){
                        	input.attr("datatype",cellData.datatype);
                        	input.attr("msg",cellData.msg);
                        }
                        if(cellData.field){
                            input.attr("field",cellData.field);
                        }
						break;
					case "date":
					case "year":
                       var input = $("<input type='text' uiType='"+cellData.type+"'>").appendTo(td2);
                       if(cellData.name){
                           input.attr("name",cellData.name);
                       }
                       if(cellData.id){
                           input.attr("id",cellData.id);
                       }else{
                           input.attr("id",that.id+"_"+cellData.name);
                       }
                       input.attr("onclick","WdatePicker({dateFmt:'yyyy'})");
                       if(cellData.datatype&&cellData.msg){
                           input.attr("datatype",cellData.datatype);
                           input.attr("msg",cellData.msg);
                       }
                       if(cellData.field){
                           input.attr("field",cellData.field);
                       }
                       break;
					case "yearmonth":
					   var input = $("<input type='text' uiType='"+cellData.type+"'>").appendTo(td2);
                       if(cellData.name){
                       		input.attr("name",cellData.name);
                       }
                       if(cellData.id){
                       		input.attr("id",cellData.id);
                       }else{
                       		input.attr("id",that.id+"_"+cellData.name);
                       }
                       input.attr("onclick","WdatePicker({dateFmt:'yyyy-MM'})");
                       if(cellData.datatype&&cellData.msg){
                           	input.attr("datatype",cellData.datatype);
                            input.attr("msg",cellData.msg);
                       }
                       if(cellData.field){
                            input.attr("field",cellData.field);
                       }
                      break;
					case "datetime":
						var input = $("<input type='text' uiType='"+cellData.type+"'>").appendTo(td2);
						if(cellData.name){
							input.attr("name",cellData.name);
						}
						if(cellData.id){
							input.attr("id",cellData.id);
						}else{
							input.attr("id",that.id+"_"+cellData.name);
						}
						input.attr("onclick","WdatePicker()");
						if(cellData.datatype&&cellData.msg){
                        	input.attr("datatype",cellData.datatype);
                        	input.attr("msg",cellData.msg);
                        }
                        if(cellData.field){
                            input.attr("field",cellData.field);
                        }
						break;
						case "datetime1":
                        						var input = $("<input type='text' uiType='"+cellData.type+"'>").appendTo(td2);
                        						if(cellData.name){
                        							input.attr("name",cellData.name);
                        						}
                        						if(cellData.id){
                        							input.attr("id",cellData.id);
                        						}else{
                        							input.attr("id",that.id+"_"+cellData.name);
                        						}
                        						input.attr("onclick","WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})");
                        						if(cellData.datatype&&cellData.msg){
                                                	input.attr("datatype",cellData.datatype);
                                                	input.attr("msg",cellData.msg);
                                                }
                                                if(cellData.field){
                                                    input.attr("field",cellData.field);
                                                }
                        						break;
					case "datescale":
						var input = $("<input type='text' size='10' uiType='"+cellData.type+"'>").appendTo(td2);
						if(cellData.name){
							input.attr("name",cellData.name);
						}
						if(cellData.id){
							input.attr("id",cellData.id);
						}else{
							input.attr("id",that.id+"_"+cellData.name);
						}
						input.attr("onclick","WdatePicker()");//end
						td2.append("-");
						input = $("<input size='10' type='text' uiType='"+cellData.type+"'>").appendTo(td2);
						if(cellData.name){
							input.attr("name",cellData.name);
						}
						if(cellData.id){
							input.attr("id",cellData.id+"_2");
						}else{
							input.attr("id",that.id+"_"+cellData.name+"_2");
						}
						input.attr("onclick","WdatePicker()");
						if(cellData.field){
                            input.attr("field",cellData.field);
                        }
						break;
					case "select":
						var select = null;
						if(cellData.dic){
							var dic = eval("dic"+cellData.dic);
							select = dicSelect(dic);
						}else{
							select = joinSelect({data:cellData["map"],valueKey:"id",textKey:"name"});
						}
						if(cellData.id){
							select.attr("id",cellData.id);
						}
						if(cellData.width){
                            select.css("width",cellData.width);
                        }
						select.appendTo(td2).attr("uiType","select").attr("name",cellData.name);
						if(cellData.disabled){
							select.attr("disabled",cellData.disabled);
						}
						if(cellData.datatype&&cellData.msg){
                            select.attr("datatype",cellData.datatype);
                            select.attr("msg",cellData.msg);
                        }
                        if(cellData.field){
                            select.attr("field",cellData.field);
                        }
						break;
					case "pop":
					case "popText":
						var input = $("<input uiType='pop' type='text'>").appendTo(td2);
						if(cellData.name){
							input.attr("name",cellData.name+"_txt");
						}
						if(cellData.id){
							input.attr("id",cellData.id);
						}else{
							input.attr("id",that.id+"_"+cellData.name+"_txt");
						}
						if(cellData.type==="pop"){
							input.bind('click',{fn:cellData.fn,title:cellData.title},function(e){
								window[e.data.fn](e,this,e.data.title);
							});
						}
						if(cellData.field){
                            input.attr("field",cellData.field);
                        }

						var input2 = $("<input uiType='pop' type='hidden'>").appendTo(td2);
						if(cellData.name){
							input2.attr("name",cellData.name);
						}
						if(cellData.id){
							input2.attr("id",cellData.id);
						}else{
							input2.attr("id",that.id+"_"+cellData.name);
						}
						if(cellData.field){
                            input2.attr("field",cellData.field);
                        }
						break;
					case "autocomplete":
						var input = $("<input uiType='autocomplete' type='text'>").appendTo(td2);
						if(cellData.name){
							input.attr("name",cellData.name+"_txt");
						}
						if(cellData.id){
							input.attr("id",cellData.id);
						}else{
							input.attr("id",that.id+"_"+cellData.name+"_txt");
						}
						var input2 = $("<input uiType='autocomplete' type='hidden'>").appendTo(td2);
						if(cellData.name){
							input2.attr("name",cellData.name);
						}
						if(cellData.id){
							input2.attr("id",cellData.id);
						}else{
							input2.attr("id",that.id+"_"+cellData.name);
						}

						break;
					case "hidden":
                        var input = $("<input type='hidden' uiType='"+cellData.type+"' />").appendTo(td2);
                        if(cellData.value){
                            input.attr("value",cellData.value);
                        }
                        if(cellData.name){
                            input.attr("name",cellData.name);
                        }
                        if(cellData.id){
                            input.attr("id",cellData.id);
                        }else{
                            input.attr("id",that.id+"_"+cellData.name);
                        }
                        if(cellData.width){
                            input.css("width",cellData.width);
                        }
                        if(cellData.disabled){
                            input.attr("disabled",cellData.disabled);
                        }
                        if(cellData.field){
                            input.attr("field",cellData.field);
                        }
                        break;
                    case "selknow":
                        var input = $("<input type='text' onclick='selknow()' uiType='"+cellData.type+"' />").appendTo(td2);
                        if(cellData.value){
                            input.attr("value",cellData.value);
                        }
                        if(cellData.name){
                            input.attr("name",cellData.name);
                        }
                        if(cellData.id){
                            input.attr("id",cellData.id);
                        }else{
                            input.attr("id",that.id+"_"+cellData.name);
                        }
                        if(cellData.width){
                            input.css("width",cellData.width);
                        }
                        if(cellData.disabled){
                            input.attr("disabled",cellData.disabled);
                        }
                        if(cellData.field){
                            input.attr("field",cellData.field);
                        }
                        break;
                    case "div":
                        var input = $("<div uiType='"+cellData.type+"' ></div>").appendTo(td2);
                        if(cellData.value){
                            input.attr("value",cellData.value);
                        }
                        if(cellData.name){
                            input.attr("name",cellData.name);
                        }
                        if(cellData.id){
                            input.attr("id",cellData.id);
                        }else{
                            input.attr("id",that.id+"_"+cellData.name);
                        }
                        if(cellData.width){
                            input.css("width",cellData.width);
                        }
                        if(cellData.height){
                            input.css("height",cellData.height);
                        }
                        if(cellData.disabled){
                            input.attr("disabled",cellData.disabled);
                        }
                        if(cellData.field){
                            input.attr("field",cellData.field);
                        }
                        if(cellData.name=="editCashRule"){
                           ueCashRule = UE.getEditor(input.attr("id"));
                        }
                        if(cellData.name=="editMemberRule"){
                           ueMemberRule = UE.getEditor(input.attr("id"));
                        }
                        if(cellData.name=="editRaiderEntrance"){
                           ueRaiderEntrance = UE.getEditor(input.attr("id"));
                        }
                        if(cellData.name=="editMoneyRaider"){
                           ueMoneyRaider = UE.getEditor(input.attr("id"));
                        }
                        if(cellData.name=="editMoneyRule"){
                           ueMoneyRule = UE.getEditor(input.attr("id"));
                        }
                        if(cellData.name=="editComProblem"){
                           ueComProblem = UE.getEditor(input.attr("id"));
                        }
                        if(cellData.name=="editAboutUs"){
                           ueAboutUs = UE.getEditor(input.attr("id"));
                        }
                        if(cellData.name=="editRegProtocol"){
                           ueRegProtocol = UE.getEditor(input.attr("id"));
                        }
                        if(cellData.name=="editNoticeNote"){
                           ueNoticeNote = UE.getEditor(input.attr("id"));
                        }
                        if(cellData.name=="editDemoNote"){
                           ueDemoNote = UE.getEditor(input.attr("id"));
                        }
                        break;
                    case "uploadimg":
                        var input = $("<img uiType='uploadimg' onerror=javascript:this.src='"+g_path+"/static/images/uploadpic.jpg' src='"+g_path+"/static/images/uploadpic.jpg' onclick='uploadimg(this)' />").appendTo(td2);
                        if(cellData.value){
                           input.attr("src",cellData.value);
                        }
                        if(cellData.name){
                           input.attr("name",cellData.name);
                        }
                        if(cellData.id){
                           input.attr("id",cellData.id);
                        }else{
                           input.attr("id",that.id+"_"+cellData.name);
                        }
                        if(cellData.width){
                           input.css("width",cellData.width);
                        }
                        if(cellData.field){
                           input.attr("field",cellData.field);
                        }
                        break;
                    case "uploadfile":
                        var input = $("<input type='text' uiType='"+cellData.type+"' onclick='uploadfile(this)' />").appendTo(td2);
                        if(cellData.name){
                            input.attr("name",cellData.name);
                        }
                        if(cellData.id){
                            input.attr("id",cellData.id);
                        }else{
                            input.attr("id",that.id+"_"+cellData.name);
                        }
                        if(cellData.width){
                            input.css("width",cellData.width);
                        }
                        if(cellData.disabled){
                            input.attr("disabled",cellData.disabled);
                        }
                        if(cellData.datatype&&cellData.msg){
                            input.attr("datatype",cellData.datatype);
                            input.attr("msg",cellData.msg);
                        }
                        if(cellData.field){
                            input.attr("field",cellData.field);
                        }
                        break;
					}

				}

			}
			if(that.setting.toolbar){
				var wrapDiv = $("<div class='rtit2'></div>").prependTo(wrap);
				var titleDiv = $("<div class='rtit2l'>"+that.setting.title+"</div>").prependTo(wrapDiv);
				var toolbarDiv = $("<div class='rtit2r'></div>").appendTo(wrapDiv);
				wrapDiv.append($("<div class='clear'></div>"));
				var toolbar =that.setting.toolbar;
				var buttons = toolbar.buttons;
				for(var i=0;i<buttons.length;i++){
					var button = buttons[i];
					var cssclass="btnblue";
					if(button.cssclass){
					    cssclass=button.cssclass;
					}
					var btnElement = $("<a href='javascript:void(0)' class='"+cssclass+"'></a>").attr("id",button.id).html(button.title).appendTo(toolbarDiv);
					if(button.handlers){
						var eventNames = _.keys(button.handlers);
						for(var j=0;j<eventNames.length;j++){
							btnElement.bind(eventNames[j],button.handlers[eventNames[j]]);
						}
					}
				}
				wrapDiv.prependTo(wrap);
			}
			if(that.setting.type&&that.setting.type==="query"){
				if(that.setting.title){
					$("<div class='rtit'>"+that.setting.title+"</div>").appendTo(wrap);
				}
			}
			if(that.setting.queryRow){
				/*var tdNum = 0;
				table.find("tr:first").find("td").each(function(i,td){
					var colspan = $(td).attr("colspan");
					colspan = colspan===undefined?1:colspan;
					tdNum += parseInt(colspan);
				})
				var td = $("<td>").attr("colspan",tdNum).attr("align",that.setting.queryRow.align);
				var tr = $("<tr>").append(td);*/
				var td=$("<td>");
				$(that.setting.queryRow.buttons).each(function(j,buttonConf){
					var button = $("<input type='button' class='btn2' value='" +buttonConf.title+"'/>").attr("id",buttonConf.id);
					if(buttonConf.handlers){
						$(buttonConf.handlers).each(function(k,handlerConf){
							if(handlerConf.click){
								button.bind("click",function(btnEv){
									handlerConf.click(btnEv,$('#'+that.id+" form"));
								})
							}
						})
					}
					if(buttonConf.hide){
						button.hide();
					}
					if(buttonConf.disabled){
						button.attr("disabled",true);
					}
					td.append(button);
				})
				table.find("tr:first").append(td);
			}
			wrap.append(table);
			table.wrap($("<div class='edit_con'><form></form></div>"));
			var hiddens = that.setting.hiddens;
			var form = wrap.find("form");
			if(that.setting.formid){
			  form.attr("id",that.setting.formid);
			}
			if(hiddens){
				for(var i=0;i<hiddens.length;i++){
					form.append("<input name='"+hiddens[i] + "' type='hidden' uiType='hidden'/>");
				}
			}
		}
	})

}
FormView.prototype.setValue = function(name,value){
	var input = $('#'+this.id).find(":input[name="+name+"],select[name="+name+"]");
	if(input.attr("uiType")==="pop"||input.attr("uiType")==="autocomplete"){
		var rowIndex = input.closest("tr[rowIndex]").attr("rowIndex");
		input.siblings("input").val(_.findWhere(this.setting.fields[rowIndex-1],{name:name}).map[value].name);
		input.val(value);
	}else{
		input.val(value);
	}
}
FormView.prototype.getValue = function(name){
	var input = $('#'+this.id).find(":input[name="+name+"],select[name="+name+"]");
	return input.val();
}
FormView.prototype.reset = function(){
	var form = $("#"+this.id + " form");
	form[0].reset();
	$('input[name=id]').val("");
	// autocomplete的hidden项不会reset()，只能在此强制清空
	form.find('input[uitype="autocomplete"][type="hidden"]').val('');
}
FormView.prototype.save = function(callback){
	var obj = this;
	var inputs = $('#'+this.id).find(":input[uiType],select[uiType],img[uiType]");
	var data = {};
	var oldData="";
	if(retJson!=null&&retJson!=""){
	    oldData=JSON.parse(retJson);
	}

	var y=1;
	var rdoName;
	inputs.each(function(i,el){
	    if(rdoName!=el.name){
	        y=1;
	    }

	    if(el.src){
	       data[el.name] = el.src;
	    }
	    else if(el.type=="radio"){
	       rdoName=el.name;
	       data[el.name]=$("input:radio[name='"+el.name+"']:checked").val();
	    }
	    else{
	       data[el.name] = el.value;
	    }

	    if(obj.setting.po=="QhTask"&&oldData!=""&&oldData[el.name]!=data[el.name]){
           if(y==1){
	          var field="";
	          if($("input[name='"+el.name+"']").attr("field")==undefined){
	              field=$("select[name='"+el.name+"']").attr("field");
	          }
	          else{
	              field=$("input[name='"+el.name+"']").attr("field");
	          }
              $.getJSON(g_path+"/public/common/addTaskOperLog.htmls",{object:$("input[name=title]").val(),content:field,modifyCont:data[el.name]},function(data){
              });
           }

           if(el.type=="radio"){
           	  y++;
           }
        }

		if(obj.setting.po=="QhSysPar"){
		   if(el.name=="cashRule"){
		      data[el.name]=ueCashRule.getContent();
		   }
		   if(el.name=="memberRule"){
           	  data[el.name]=ueMemberRule.getContent();
           }
           if(el.name=="raiderEntrance"){
              data[el.name]=ueRaiderEntrance.getContent();
           }
           if(el.name=="moneyRaider"){
              data[el.name]=ueMoneyRaider.getContent();
           }
           if(el.name=="moneyRule"){
              data[el.name]=ueMoneyRule.getContent();
           }
           if(el.name=="comProblem"){
              data[el.name]=ueComProblem.getContent();
           }
           if(el.name=="aboutUs"){
              data[el.name]=ueAboutUs.getContent();
           }
           if(el.name=="regProtocol"){
              data[el.name]=ueRegProtocol.getContent();
           }
		}
		if(obj.setting.po=="QhNotice"){
           if(el.name=="note"){
           	  data[el.name]=ueNoticeNote.getContent();
           }
		}
		if(obj.setting.po=="QhDemo"){
           if(el.name=="note"){
              data[el.name]=ueDemoNote.getContent();
           }
        }
	});

	$.ajax({
		url:g_path + "/public/tool/saveOrUpdateRecords.htmls",
		type:"POST",
		dataType:"json",
		data:{poName:obj.setting.po,iscreate:obj.setting.iscreate,data:[data]},
		success:function(ret){

		  if(obj.setting.po=="MathKnowSub"){
		     $.get(g_path+"/public/common/deleteMathSubKnowid.htmls",{pid:ret.id},function(data){

		        var knowid=$("input[name=hdknow]").val().split(",");
               		     for(var i=0;i<knowid.length;i++){
               		        var data = {};
                               data["pid"]=ret.id;
                               data["knowid"]=knowid[i];

                               $.ajax({
                                 url:g_path + "/public/tool/saveOrUpdateRecords.htmls",
                                 type:"POST",
                                 dataType:"json",
                                 async:false,
                                 data:{poName:"MathSubKnowid",data:[data]},
                                 success:function(msg){

                                 }
                               });
                            }
		     });

          }
		  if(ret.message){
			 if(callback){
				callback(ret);
			 }
		  }else{
			 layer.alert("数据保存失败");
		  }
		}
	})
}
FormView.prototype.loadData = function(id,poName,callback){
	var obj = this;
	var fields = obj.setting.fields;
	var inputs = $('#'+this.id).find(":input[uiType],select[uiType],img[uiType]");
	$.ajax({
		url:g_path + "/public/tool/loadFormData.htmls",
		type:"POST",
		dataType:"json",
		data:{poName:obj.setting.po,id:id},
		success:function(ret){
		    retJson=JSON.stringify(ret);
			inputs.each(function(i,el){
				var name = el.name;

				if(($(el).attr("uiType")==="hidden")){
					el.value = ret[name]===undefined ? "" : ret[name];
				}
				else if($(el).attr("uiType")==="radio"){
				    $("input[name='"+name+"'][value="+ret[name]+"]").attr("checked",true);
				}
				else{
					var cellData = _.findWhere(fields[$(el).closest('tr').attr("rowIndex")-1],{name:name});
					if(!_.has(cellData,'map')){
					    if(el.src){
                        	el.src = ret[name];
                        }
                        else{
                            if($(el).attr("uiType")!=="file")
                              el.value = ret[name]===undefined?"":ret[name];
						}
					}else{
						if($(el).is(":hidden")){//弹出框的uiType="pop"
							if(_.has(ret,name)){
								el.value = ret[name];
								if(cellData.map[ret[name]]){
									$(el).siblings(":input[uiType]").val(cellData.map[ret[name]].name);
								}
							}
						}else{
                            el.value = ret[name];
						}
					}
				}

                if(obj.setting.po=="QhSysPar"){
                   var val=ret[name]===undefined ? "" : ret[name];
                   if(name=="cashRule"){
                      ueCashRule.addListener("ready", function () {
                   	     ueCashRule.setContent(val);
                   	  });
                   }
                   if(name=="memberRule"){
                      ueMemberRule.addListener("ready", function () {
                   	     ueMemberRule.setContent(val);
                   	  });
                   }
                   if(name=="raiderEntrance"){
                      ueRaiderEntrance.addListener("ready", function () {
                         ueRaiderEntrance.setContent(val);
                      });
                   }
                   if(name=="moneyRaider"){
                      ueMoneyRaider.addListener("ready", function () {
                         ueMoneyRaider.setContent(val);
                      });
                   }
                   if(name=="moneyRule"){
                      ueMoneyRule.addListener("ready", function () {
                         ueMoneyRule.setContent(val);
                      });
                   }
                   if(name=="comProblem"){
                      ueComProblem.addListener("ready", function () {
                         ueComProblem.setContent(val);
                      });
                   }
                   if(name=="aboutUs"){
                      ueAboutUs.addListener("ready", function () {
                         ueAboutUs.setContent(val);
                      });
                   }
                   if(name=="regProtocol"){
                      ueRegProtocol.addListener("ready", function () {
                         ueRegProtocol.setContent(val);
                      });
                   }
				}
				if(obj.setting.po=="QhNotice"){
                   if(name=="note"){
                      ueNoticeNote.addListener("ready", function () {
                         ueNoticeNote.setContent(val);
                      });
                   }
				}
				if(obj.setting.po=="QhDemo"){
				   var val=ret[name]===undefined ? "" : ret[name];
                   if(name=="note"){
                      ueDemoNote.addListener("ready", function () {
                         ueDemoNote.setContent(val);
                      });
                   }
                }
			})
		}
	})
}

function selknow(){
  layer.open({
      title:false,
      type: 2,
      skin: 'layui-layer-rim', //加上边框
      area: ['400px', '400px'], //宽高
      content: [g_path+'/public/common/r2.htmls?page=content/math_know_list&issub=1',"auto"],
      end:function(ret){

      }
  });
}
function uploadimg(obj){
    $('#fmUploadImg').show();
    layer.open({
    	  title : "上传图片",
    	  type : 1,
    	  skin : 'layui-layer-lan', // 加上边框
    	  area : [ '400px', '200px' ], // 宽高
    	  content : $("#fmUploadImg"),
    	  btn : [ "确定", "取消" ],
    	  yes : function(index, layero) {
    	     var form = new FormData(document.getElementById("form1"));
          $.ajax({
             url:g_path+"/public/aliyun/uploadimg.htmls",
             type:"POST",
             data: form,
             processData:false,
             contentType:false,
             success:function(ret){
                $("#"+$(obj).attr("id")).attr("src",ret);
             }
          })
          layer.close(index);
    	  },
    	  end : function(ret) {
       }
    });
}

function uploadfile(obj){
   $('#fmUploadFile').show();
   layer.open({
   	  title : "上传文件",
   	  type : 1,
   	  skin : 'layui-layer-lan', // 加上边框
   	  area : [ '400px', '200px' ], // 宽高
   	  content : $("#fmUploadFile"),
   	  btn : [ "确定", "取消" ],
   	  yes : function(index, layero) {
   	     var form = new FormData(document.getElementById("formFile"));
         $.ajax({
            url:g_path+"/public/aliyun/uploadapk.htmls",
            type:"POST",
            data:form,
            processData:false,
            contentType:false,
            success:function(ret){
               $("#"+$(obj).attr("id")).val(ret);
            }
         })
         layer.close(index);
   	  },
   	  end : function(ret) {
      }
   });
}